package com.example.entity;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@NoArgsConstructor
@AllArgsConstructor
public class Result {

    /**
     * 响应状态码
     */
    private Integer code;

    /**
     * 响应信息
     */
    private String message;

    /**
     * 响应数据
     */
    private Object data;

    /**
     * 响应成功
     *
     * @param message
     * @param data
     * @return
     */
    public static Result success(String message, Object data) {
        return new Result(200, message, data);
    }

    /**
     * 响应成功
     *
     * @return
     */
    public static Result success() {
        return new Result(200, "success", null);
    }

    /**
     * 响应失败
     *
     * @param message
     * @return
     */
    public static Result fail(String message) {
        return new Result(400, message, null);
    }

    /**
     * 响应失败
     *
     * @return
     */
    public static Result fail() {
        return new Result(400, "fail", null);
    }

}
